local plof = io.open("present&location.txt",'r')
local present = {}
local location = {}

local i = 1
for line in plof:lines() do
    local pre, loc
    pre, loc = string.match(line,"^%s*(%w+)%s*(.*)")
    present[i] = pre
    location[i] = loc
    i = i + 1
end

plof:close()

function ChoosePresent(birthday)
    math.randomseed(birthday)
    local index = math.random(#present)
    return present[index], index
end

function LocationPresent(presentindex)
    return location[presentindex]
end

while true do
    print("-->input the birthday")
    local birthday = tonumber(io.read())
    local temppresent, index = ChoosePresent(birthday)
    print("*The choosen random present: " .. temppresent)
    print([[
->show location? (l)
->quit? (q)]])
    local flag = io.read()
    if flag == 'l' then print("*Present " .. temppresent .. " can be bought at: " .. LocationPresent(index))
    elseif flag == 'q' then break
    else --pass 
    end
end